package com.ice.day726.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/**
 * @Author ice2020x
 * @Date 2022-07-26 12:54
 * @Description:
 */

@Slf4j
public class ThreadTest3 {
    public static void main(String[] args) {

        FutureTask<Integer> future = new FutureTask<Integer>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                log.debug("running...");
                Thread.sleep(10000000);
                return 20;
            }
        });
        new Thread(future).start();
        try {
            Integer integer = future.get();
            log.debug("结果是："+integer);
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }

    }
}
